home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / nwpep.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  3KB  |  97 lines

  1. {$B-,V-,X+}
  2. UNIT nwPEP;
  3.  
  4. { nwPEP unit as of 950301 / NwTP 0.6 API. (c) 1993,1995, R.Spronk }
  5.  
  6. INTERFACE
  7.  
  8. Uses Dos,nwIPX,nwMisc;
  9.  
  10. { Primary IPX calls:           Subf:  Comments:
  11.  
  12.   Secondary calls:
  13.  
  14.   PEPsetupSendECB
  15.   PEPsetupListenECB
  16.  
  17. }
  18.  
  19. Var Result:word; { unit errorcode variable }
  20.  
  21. Type TpepHeader=Record
  22.                IPXhdr       :TipxHeader;  { set packettype to $04 }
  23.                TransactionID:Longint;
  24.                clientType   :word;
  25.                end;
  26.  
  27. Procedure PEPSetupListenECB(ESRptr:Pointer; ReceiveSocket:word;
  28.                             BufPtr:Pointer; BufSize:word;
  29.                      {out:} Var PepHdr:TpepHeader; Var ecb:Tecb);
  30. { Clears IPXheader and ECB, sets values of the required fields within
  31.   the ecb and IPX header. }
  32.  
  33. Procedure PEPSetupSendECB(ESRptr:pointer; SourceSocket:word;
  34.                           DestAddr:TinterNetworkAddress;
  35.                           BufPtr:pointer; BufSize:word;
  36.                    {out:} Var PepHdr:TpepHeader; Var ecb:Tecb);
  37. { Clears IPXheader and ECB, sets values of the required fields within
  38.   the ecb and IPX header. }
  39.  
  40. IMPLEMENTATION {==============================================================}
  41.  
  42. Procedure PEPSetupListenECB(ESRptr:Pointer;ReceiveSocket:word;
  43.                             BufPtr:Pointer;BufSize:word;
  44.                      {out:} Var PepHdr:TpepHeader; Var ecb:Tecb);
  45. { Clears IPXheader and ECB, sets values of the required fields within
  46.   the ecb and IPX header. }
  47. { ECB: ESR adress field, socket number, fragment count, frag.descriptor fields }
  48. begin
  49. FillChar(ecb,SizeOf(Tecb),#0);
  50. FillChar(pepHdr,SizeOF(TpepHeader),#0);
  51. WITH ECB
  52.  do begin
  53.     if ESRptr<>NIL
  54.      then ESRaddress:=ESRptr;
  55.     Fragmentcount:=2;
  56.     socketNumber:=swap(ReceiveSocket); {hi-lo}
  57.  
  58.     Fragment[1].Address:=@pepHdr;
  59.     Fragment[2].Address:=BufPtr;
  60.     Fragment[1].size:=SizeOf(Tpepheader);
  61.     Fragment[2].size:=BufSize;
  62.     end;
  63. end;
  64.  
  65. Procedure PEPsetupSendECB(ESRptr:pointer; SourceSocket:word;
  66.                           DestAddr:TinterNetworkAddress;
  67.                           BufPtr:pointer; BufSize:word;
  68.                    {out:} Var PepHdr:TpepHeader; Var ecb:Tecb);
  69. { Clears IPXheader and ECB, sets values of the required fields within
  70.   the ecb and IPX header. }
  71. Var ImmAddr:TnodeAddress;
  72.     Ticks:word;
  73. begin
  74. fillchar(pepHdr,SizeOf(TpepHeader),#0);
  75. with pepHdr.IPXhdr
  76.  do begin
  77.     PacketType:=PEP_PACKET_TYPE;
  78.     Move(DestAddr,Destination,10);
  79.     destination.socket:=swap(DestAddr.socket); {hi-lo}
  80.     end;
  81. IPXGetLocalTarget(DestAddr,ImmAddr,Ticks);
  82. fillchar(ecb,sizeOf(ecb),#0);
  83. With ecb
  84.  do begin
  85.     if ESRptr<>NIL
  86.      then ESRaddress:=ESRptr;
  87.     socketNumber:=swap(SourceSocket); {hi-lo}
  88.     Move(ImmAddr,ImmediateAddress,6);
  89.     FragmentCount:=2;
  90.     fragment[1].Address:=@pephdr;
  91.     fragment[1].size:=SizeOf(TpepHeader);
  92.     fragment[2].Address:=BufPtr;
  93.     fragment[2].size:=BufSize;
  94.     end;
  95. end;
  96.  
  97. end.